export default {

	//开启命名空间
	namespaced: true,

	//准备actions对象——响应组件中用户的动作
	actions: {
		
		//点击时显示对应的商品内容
		change(context, value) {
			
			//筛选出对应的商品列表
			let list = context.state.commodity.filter( item=>{
				return item.ilk == value
			})
			context.commit('CHANGE',list)
		},
		
		//搜索显示对应的商品内容
		searchList(context,value) {
			//筛选出对应的商品列表
			let list = context.state.commodity.filter( item=>{
				return item.title.indexOf(value) != -1 || item.ilk.indexOf(value) != -1
			})
			console.log(value)
			console.log(list)
			context.commit('SEARCHLIST',list)
		},
		

	},

	//准备mutations对象——修改state中的数据
	mutations: {
	
	CHANGE(state,value) {
		
		//存入对应列表的数据
		state.activeList = value
		
	},
	
	SEARCHLIST(state,value) {
		
		//存入对应列表的数据
		state.searchResult = value
		
	}


	},

	getters:{
		
		
	},

	//准备state对象——保存具体的数据
	state: {
		//首页推荐
		homerecommend:[
			{
				ilk: '铁观音',
				title: '消青工艺浓香铁观音1号',
				price: '128.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '龙井',
				title: '浓郁豆香龙井1号',
				price: '199.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '金骏眉',
				title: '全芽黄芽金骏眉2号',
				price: '99.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '英德红茶',
				title: '英德红茶-英红九号',
				price: '100.00',
				pic: './images/product.jpeg'
			},
		],
		
		//搜索结果
		searchResult:[],
		
		//
		activeList:[],
		
		// 商品数据
		commodity: [
			{
				ilk: '铁观音',
				title: '消青工艺浓香铁观音1号',
				price: '128.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '铁观音',
				title: '消青工艺浓香铁观音2号',
				price: '188.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '铁观音',
				title: '消青工艺浓香铁观音3号',
				price: '98.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '铁观音',
				title: '安溪清香型铁观音',
				price: '108.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '铁观音',
				title: '铁观音-橙色招财进宝礼盒',
				price: '99.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '龙井',
				title: '浓郁豆香龙井1号',
				price: '199.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '龙井',
				title: '浙江果栗香雨前龙井2号',
				price: '59.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '龙井',
				title: '传统栗香龙井3号',
				price: '109.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '龙井',
				title: '明前一级春茶龙井破春',
				price: '198.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '龙井',
				title: '2022春茶明前龙井飞花',
				price: '98.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '金骏眉',
				title: '浅尝-灰芽金骏眉',
				price: '128.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '金骏眉',
				title: '全芽黄芽金骏眉2号',
				price: '99.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '金骏眉',
				title: '武夷山灰芽花香金骏眉3号',
				price: '199.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '金骏眉',
				title: '金骏眉礼盒-红色迎客赋',
				price: '399.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '金骏眉',
				title: '山境煮茗金骏眉 瓷罐礼盒',
				price: '198.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '英德红茶',
				title: '英德红茶-英红九号',
				price: '100.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '正山小种',
				title: '浅尝-蜜香小种（正山小种）',
				price: '98.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '正山小种',
				title: '无烟工艺正山小种2号',
				price: '128.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '正山小种',
				title: '新工艺正山小种3号',
				price: '128.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '正山小种',
				title: '正山小种礼盒-蓝色迎客赋',
				price: '100.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '生茶',
				title: '2016南糯山古树普洱生茶',
				price: '128.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '生茶',
				title: '海潮七子饼茶-生普',
				price: '128.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '生茶',
				title: '丁家寨古树生茶',
				price: '68.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '生茶',
				title: '丁家寨古树生茶',
				price: '128.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '熟茶',
				title: '云南糯米香小熟沱普洱',
				price: '59.00',
				pic: './images/product.jpeg'
			},
			{
				ilk: '茉莉花茶',
				title: '茶师林灿茉莉雪芽',
				price: '128.00',
				pic: './images/product.jpeg'
			},
		]

	},
}
